<html>
<body>
<p>The "Origin" header must be sent with a "non-simple" cross-origin resource sharing request that uses the GET method and specifies "blob" as response type.</p>
<pre id="console"></pre>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(message)
{
    document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
}


function test()
{
    var xhr = new XMLHttpRequest();
    xhr.responseType = "blob";
    xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/cross-origin-preflight-get.php", true);
    // Make this a "non-simple" cross-origin request by adding a custom header.
    xhr.setRequestHeader("X-Proprietary-Header", "foo");
    xhr.onerror = function() {
        log("xhr onerror");
        if (window.testRunner)
            testRunner.notifyDone();
    }
    xhr.onload = function() {
        var reader = new FileReader;
        reader.onload = function(evt) {
            log(evt.target.result);
        };
        reader.onerror = () => {
            log("reader.onerror");
        };
        reader.onloadend = () => {
            if (window.testRunner)
                testRunner.notifyDone();
        };
        reader.readAsText(xhr.response);
    }
    xhr.send(null);
}

test();
</script>
</body>
</html>
